﻿    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EzDesk.Core.Model;
using System.ServiceModel;

namespace EzDesk.Core.Interface
{
    [ServiceContract]
    public interface ICoreAppService
    {
        #region [ Globle Info ]
        [OperationContract]
        Organization GetOrganizationInfo();
        #endregion

        #region [ UserInfos ]
        [OperationContract]
        UserProfile GetUserProfileById(Guid userId);

        [OperationContract]
        IList<UserProfile> GetUserProfiles(string memberstring);

        [OperationContract]
        SimpleUser GetSimpleUserById(Guid userId);

        [OperationContract]
        IList<SimpleUser> GetSimpleUserInfos(string memberstring);

        [OperationContract]
        IList<Dept> GetAllDepts();

        [OperationContract]
        void UpdateHeadIcon(Guid userId, byte[] iconData, string iconType);

        [OperationContract]
        UserHeadImage GetHeadIcon(Guid userId);

        [OperationContract]
        Guid? CreateNewUser(UserProfile newUserProfile, string newPassword);

        [OperationContract]
        void UpdateUserProfile(UserProfile userProfile);

        [OperationContract]
        void ChangePassword(Guid userId, string oldPassword, string newPassword);
        #endregion

        #region [ Groups && Memberstrings ]
        [OperationContract]
        IList<SimpleUser> GetAllUsersByMemberString(string memberString);
        [OperationContract]
        IDictionary<Guid, string> GetChildrenByMemberString(string memberString);
        [OperationContract]
        Group GetGroupByName(string groupName);
        [OperationContract]
        IList<Group> GetAllSystemGroups();
        [OperationContract]
        Group GetSystemGroup(string groupName);

        [OperationContract]
        Group GetGroupById(Guid groupId);
        [OperationContract]
        IList<Group> GetGroups(string groupIdStrs);
        #endregion

        #region [ Feed Methods ]

        [OperationContract(Name="SendFeedByName")]
        Guid SendFeed(string templateName, string feedData, string memberString, Guid? senderId, string ignoreUsers, bool isAvailable);
        [OperationContract]
        void UpdatePersonalFeedData(Guid feedId, string memberstring, string feedDataEx);
        [OperationContract]
        void UpdatePersonalFeedType(Guid feedId, string memberstring, string feedTypeStr);

        [OperationContract]
        void SetFeedRecord(Guid identity, string templateName, string memberstring, Guid feedId, string ignoreUsers);
        [OperationContract]
        string GetFeedRecord(Guid identity, string templateName, string userId);
        
        [OperationContract]
        void UpdateFeedData(Guid updateFeedId, string newFeedData);
        [OperationContract]
        void UpdateFeedsData(string updateFeeds, string updateFeedData);

        [OperationContract]
        void SetFeedIsAvailable(Guid feedId, string memberString, bool isAvailable);
        [OperationContract]
        void SetFeedsIsAvailable(string feedIdStrs, string memberString, bool isAvailable);

        [OperationContract]
        void SetFeedIsRead(Guid feedId, string memberString, bool isRead);
        [OperationContract]
        void SetFeedsIsRead(string feedIdStrs, string memberString, bool isRead);
        #endregion

        #region [ Permissions ]
        /// <summary>
        /// 用户是否拥有权限
        /// </summary>
        /// <param name="permissionStr">用户权限字符串</param>
        /// <param name="userId">用户Id</param>
        /// <returns></returns>
        [OperationContract]
        bool UserHasPermission(string permissionStr, Guid userId);


        /// <summary>
        /// 用户组是否拥有权限
        /// </summary>
        /// <param name="permissionStr">用户权限字符串</param>
        /// <param name="userId">用户组Id</param>
        /// <returns></returns>
        [OperationContract]
        bool GroupHasPermission(string permissionStr, Guid groupId);
        #endregion
    }
}
